export function Context(data,ctx){
	var text = data; //这是要绘制的文本
	var chr = text.split(''); //这个方法是将一个字符串分割成字符串数组
	var temp = '';
	var row = [];
	ctx.setFontSize(16);
	ctx.setFillStyle('#000');
	for (var a = 0; a < chr.length; a++) {
		if (ctx.measureText(temp).width < 250) {
			temp += chr[a];
		} else {
			a--; //这里添加了a-- 是为了防止字符丢失，效果图中有对比
			row.push(temp);
			temp = '';
		}
	}
	row.push(temp);
	if(row.length <= 1){
		const metricsPrice = ctx.measureText(row[0]);
		const Price = (250 - metricsPrice.width) / 2;
		ctx.fillText(row[0], Price, 290, 250);
	}
	//如果数组长度大于2 则截取前两个
	if (row.length > 1) {
		var rowCut = row.slice(0, 2);
		var rowPart = rowCut[1];
		var test = '';
		var empty = [];
		for (var a = 0; a < rowPart.length; a++) {
			if (ctx.measureText(test).width < 220) {
				test += rowPart[a];
			} else {
				break;
			}
		}
		empty.push(test);
		if(ctx.measureText(test).width > 220){
			var group = empty[0] + '...'; //这里只显示两行，超出的用...表示
		}else{
			var group = empty[0]; //这里只显示两行，超出的用...表示
		}
		rowCut.splice(1, 1, group);
		row = rowCut;
		for (var b = 0; b < row.length; b++) {
			ctx.fillText(row[b], 20, 290 + b * 20, 210);
		}
	}
}